(function() {
    let newData = [];
    let info = document.querySelector(".info")
    function render(data = []) {
        newData = [...newData ,  ...data]
        let html = "";
        newData.forEach(item => {
            html += `
            <li productid="${item.productId}">
                <a>
                    <div class="img">
                        ${item.productImgSm}
                    </div>
                    <div class="infoR">
                        <div class="title">
                            <h4>
                                ${item.productName} 
                                <span>
                                    ${item.productPinkage}
                                </span>
                            </h4>
                        </div>
                        <div class="other">
                            <span>${item.productFrom} | ${item.productTime}</span>
                            <em class="fr">
                                <i>
                                    
                                </i>
                                <span>
                                    ${item.productComCount}
                                </span>
                            </em>
                        </div>
                    </div>
                </a>
            </li>
            `
        })
        info.innerHTML = html
        let lis = [...info.children];

        lis.forEach(li => {
            li.onclick = function () {
                let productid = this.getAttribute("productid")
                location.href = `./detail.html?productid=${productid}`
            }
        })
    }

    ajax({
        url: "http://chst.vip:1234/api/getmoneyctrl",
            data: {
                pageid: 0
            }
        })
            .then(res => {
                console.log(res);
                render(res.result)
            } , error => {
                console.error("出错了");
    })


            
})()